import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-news',
  templateUrl: './news.component.html',
  styleUrls: ['./news.component.less']
})
export class NewsComponent implements OnInit {
  public title:string = '来自新闻组件的数据';
  public msg:any;
  public student:any = '来之动态绑定的值';
  public content:string = '<h1>angular如何解析html</h1>';
  public arr:any[] = ['a','b','c','d'];
  public cars:any[] = [
    {
      name:'宝马',
      series:[
        {
          title:'宝马一系',
          price:'30'
        },
        {
          title:'宝马二系',
          price:'40'
        },
        {
          title:'宝马三系',
          price:'50'
        }
      ]
    },
    {
      name:'奔驰',
      series: [
        {
          title:'奔驰一系',
          price:15
        },
        {
          title:'奔驰二系',
          price:25
        },
        {
          title:'奔驰三系',
          price:35
        }
      ]
    }
  ];
  public imgSrc:string = 'https://www.baidu.com/img/bd_logo1.png';
  public showText:boolean = true;
  public flag:number = 3; //1:未支付 2：已支付 3：已发货 4：已收货 5：已取消
  public classFlag:boolean = false;
  public styleColor:string = 'green';
  public time:any = new Date();
  public keyWords:any;
  constructor() {
    this.msg = '先声明后赋值'
  }

  ngOnInit() {
  }
  handleClickShow(){
    alert('点击执行弹出！')
  }
  handleClickRed(e){
    let dom:any = e.target;
    dom.style.color = 'red';
  }
  keyDown(e){
    // console.log(e);
    if (e.keyCode ===13) {
      console.log('你按下的是回车键')
    }else {
      console.log(e.target.value)
    }

  }
  keyUp(e){
    // console.log(e);
    if (e.keyCode ===13) {
      console.log('你按下的是回车键');
      e.target.value = '';
    }else {
      console.log(e.target.value)
    }
  }
  handleChangeInput(){
    this.keyWords = '修改后的值'
  }

}
